package com.sxbbc.bank.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sxbbc.bank.service.IBankMultiInformationService;
import com.sxbbc.common.core.entity.banks.BankMultiInformation;
import com.sxbbc.common.core.mapper.banks.BankMultiInformationMapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2020-09-07
 */
@Service
public class BankMultiInformationServiceImpl extends ServiceImpl<BankMultiInformationMapper, BankMultiInformation> implements IBankMultiInformationService {

    public List<BankMultiInformation> list(Integer type){
        QueryWrapper<BankMultiInformation> wrapper = new QueryWrapper<>();
        if(null!=type){
            wrapper.eq("type",type);
        }
        return super.list(wrapper);
    }


    public Map<String, String> listMap(Integer type){
        QueryWrapper<BankMultiInformation> wrapper = new QueryWrapper<>();
        if(null!=type){
            wrapper.eq("type",type);
        }

        List<BankMultiInformation> list=super.list(wrapper);
        Map<String,String> map=new HashMap<>(list.size());
        for (int i = 0; i < list.size(); i++) {
           map.put(list.get(i).getId().toString(),list.get(i).getName());
        }
        return map;
    }

    public List<BankMultiInformation> listByLoanApplRecordId(Integer id){
        QueryWrapper<BankMultiInformation> wrapper = new QueryWrapper<>();
        wrapper.eq("loan_apply_record_id",id);
        wrapper.orderByAsc("sort");
        return  super.list(wrapper);
    }


}
